package com.qf.ssm.service.Impl;

import com.qf.ssm.entity.PropertyGroup;
import com.qf.ssm.ex.ServiceException;
import com.qf.ssm.mapper.PropertyGroupMapper;
import com.qf.ssm.service.PropertyGroupService;
import com.qf.ssm.utils.ResponseCode;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class PropertyGroupServiceImpl implements PropertyGroupService {
    @Resource
    PropertyGroupMapper propertyGroupMapper;

    @Override
    public List<PropertyGroup> selectDefaultDisplay() {
        try {
            return propertyGroupMapper.selectDefaultDisplay();
        } catch (Exception e) {
            throw new ServiceException(ResponseCode.GROUP_SELECT);
        }
    }

    @Override
    public PropertyGroup selectGroup(int pgId, String pgName, int status) {
        try {
            return propertyGroupMapper.selectGroup(pgId, pgName, status);
        } catch (Exception e) {
            throw new ServiceException(ResponseCode.GROUP_SELECT);
        }
    }

    @Override
    public int disable(int pmId) {
        try {
            return propertyGroupMapper.disable(pmId);
        } catch (Exception e) {
            throw new ServiceException(ResponseCode.GROUP_DISABLE);
        }
    }

    @Override
    public int enable(int pmId) {
        try {
            return propertyGroupMapper.enable(pmId);
        } catch (Exception e) {
            throw new ServiceException(ResponseCode.GROUP_ENABLE);
        }
    }

    @Override
    public int update(PropertyGroup updateGroup) {
        try {
            return propertyGroupMapper.update(updateGroup);
        } catch (Exception e) {
            throw new ServiceException(ResponseCode.GROUP_EDIT);
        }
    }

    @Override
    public int insert(PropertyGroup insertGroup) {
        try {
            return propertyGroupMapper.insert(insertGroup);
        } catch (Exception e) {
            throw new ServiceException(ResponseCode.GROUP_EDIT);
        }
    }

    @Override
    public int delete(int pgId) {
        try {
            return propertyGroupMapper.delete(pgId);
        } catch (Exception e) {
            throw new ServiceException(ResponseCode.GROUP_DELETE);
        }
    }


}
